/*
 *邀请的朋友列表
 */
require(['jquery','../modules/pageSize','../modules/popup', 'jqScroller'],function($,pageSetSize,popup){
    //设置html根目录字体大小
    setRootFontSize(pageSetSize);
    var curPagePos = 1;
    /*请求邀请的朋友列表*/
    jqScroller.render = function(cpage){
        popup.loadPopup("正在加载中...");
        $.ajax({
            type: "POST",
            url: "/Home/Member/inviteAjax"+getFixedExtraUrl(),
            data: { "page" : cpage},
            dataType: "json",
            success: function (rs) {
                popup.removeLoad();
                if(rs && rs.data != null)  {
                    renderFriendList(rs.data);
                    curPagePos++;
                    jqScroller.curPage++;
                    jqScroller.unblock();
                }else{
                    jqScroller.done();
                    if(curPagePos == 1){
                        $("#ajax-invited-list").html("<div class='no-data-txt'>没有数据！</div>");    
                    }else{                        
                        popup.alertPopup("没有更多数据！");
                    }                    
                }              
            },
            error: function () {
                popup.removeLoad();
                popup.alertPopup('服务器异常，请稍后重试！');
                jqScroller.unblock();
            }
        });
    };
    jqScroller.run();
    jqScroller.render(1);
    /*渲染邀请的朋友列表*/
    function renderFriendList(list){
        var output = "";
        var c;
        for(var k in list){
            c = list[k];
            output += '<div class="one-info">';
            if (c['logo'] == null){
                output += '<img src="/Public/Home/images/userPic.png" class="uico">';
            }else {
                output += '<img src="'+c['logo']+'" class="uico">';
            }
            output += '<div class="col-l">';
            output += '<span class="uname">'+c["username"]+'</span>';
            output += '<span class="time">'+c["time"]+'</span>';
            output += '</div>';
            output += '<div class="col-r">';
            output += '<span class="tip">累积为你带来奖金</span>';
            output += '<span class="rnum">+'+c["jlnum"]+'</span>';            
            output += '</div>';
            output += '</div>';
        }
        if(curPagePos % 10 == 0 || curPagePos == 1){
            $("#ajax-invited-list").html(output); 
        }else{
            $("#ajax-invited-list").append(output);
        }
    }
});